package dapps.web.user;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.security.springsecurity.SpringSecurityUtils;
import org.springside.modules.web.struts2.CRUDActionSupport;

import dapps.entity.user.User;
import dapps.service.user.UserManager;

@SuppressWarnings("serial")
@Results( { @Result(name = CRUDActionSupport.RELOAD, location = "password.action", type = "redirect") })
public class PasswordAction extends CRUDActionSupport<User> {

	@Autowired
	private UserManager userManager;


	// 基本属性
	private User entity;

	public User getModel() {
		return entity;
	}

	@Override
	protected void prepareModel() throws Exception {		
		entity = SpringSecurityUtils.getCurrentUser();		
	}

	// CRUD Action 函数 //

	@Override
	public String input() throws Exception {
			
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		userManager.save(entity);
		addActionMessage("修改密码成功");
		return INPUT;
	}

	@Override
	public String delete() throws Exception {
		return RELOAD;
	}

	@Override
	public String list() throws Exception {	
		
		return SUCCESS;
	}

	// 其他属性访问函数与Action函数 //

}
